package com.bc004346.travelus.utility;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

import com.bc004346.travelus.BookTravelActivity;
import com.bc004346.travelus.R;
import com.bc004346.travelus.model.domain.DayTrip;
import com.bc004346.travelus.model.domain.NotificationParameters;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * Created by Renats on 2/22/14.
 * System notification helper
 */
public class NotificationHelper {

    public static void displayNotification(NotificationParameters params) {

        Notification.Builder builder = new Notification.Builder(params.getContext());
        builder.setContentTitle(params.getTitle())
                .setContentText(params.getMessage())
                .setSmallIcon(R.drawable.ic_launcher);

        if (params.getCallback() != null) {
            Intent resultIntent = new Intent(params.getContext(), params.getCallback());
            resultIntent.putExtra(params.getExtraFlag(), params.getObject());
            PendingIntent resultPendingIntent =
                    PendingIntent.getActivity(
                            params.getContext(),
                            0,
                            resultIntent,
                            PendingIntent.FLAG_UPDATE_CURRENT
                    );
            builder.setContentIntent(resultPendingIntent);
        }

        Notification notification = builder.getNotification();

        NotificationManager mgr =
                (NotificationManager) params.getContext().getSystemService(Context.NOTIFICATION_SERVICE);

        mgr.notify(params.getNotificationID(), notification);
    }

    public static void removeNotification(Context context, int notificationID) {
        NotificationManager mgr =
                (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        mgr.cancel(notificationID);
    }
}
